addCommandHandler("skrzynki",function(plr)
    if not getElementData(plr,"player:uid") then return end
    local result=exports["cmta-db"]:dbGet("SELECT * FROM cmta_inventory WHERE uid=? LIMIT 1;",getElementData(plr,"player:uid"))
    triggerClientEvent(plr, "cmta_cases:showGUI", resourceRoot,result)
end)

addEvent('cmta_cases:addBan',true)
addEventHandler('cmta_cases:addBan',resourceRoot,function(info)
    if info == "kick" then
    kickPlayer(client)
    end
    exports["cmta-db"]:dbSet("INSERT INTO cmta_bans (nick,serial,uid,type,reason,time,banned_by) VALUES (?,?,?,?,?,NOW() + INTERVAL ? day,?)", getPlayerName(client),getPlayerSerial(client),getElementData(client, "player:uid"),"ban","Skrzynia Ryzyka", 3, "System")
end)

addEvent('cmta_cases:KeyCheck',true)
addEventHandler('cmta_cases:KeyCheck',resourceRoot,function(id)
    if id == 1 then
        local result=exports["cmta-db"]:dbGet("SELECT * FROM cmta_inventory WHERE uid=? LIMIT 1;",getElementData(client,"player:uid"))
        if result and #result > 0 then
        exports["cmta-db"]:dbSet("update cmta_inventory set key1=key1-? where uid=?",1,getElementData(client,"player:uid"))
        triggerClientEvent(client, "cmta_cases:roll", resourceRoot)
        else
        return
        end
    elseif id == 2 then
        local result=exports["cmta-db"]:dbGet("SELECT * FROM cmta_inventory WHERE uid=? LIMIT 1;",getElementData(client,"player:uid"))
        if result and #result > 0 then
            exports["cmta-db"]:dbSet("update cmta_inventory set key5=key5-? where uid=?",1,getElementData(client,"player:uid"))
            triggerClientEvent(client, "cmta_cases:roll", resourceRoot)
        else
        return
        end
    end
end)